package com.example.test2018131425.controller;

import com.example.test2018131425.bean.UserBean;
import com.example.test2018131425.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@Controller
public class RegisterController {
    @Resource
    UserService userService;

    @RequestMapping(value = "/register",method = RequestMethod.GET)
    public String register(){
        return "register";
    }


    @RequestMapping(value = "/registerUser",method = RequestMethod.POST)
    public String registerUser(UserBean userBean, HttpServletRequest request){
        int flag = userService.insertUser(userBean);
        if(flag == 1){
            return "login";
        }else {
            return "registerError";
        }
    }

}
